﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Dao;
using System.Data;

namespace Website.uc
{
    public partial class ucHome : System.Web.UI.UserControl
    {
        ItemsDao itemsDao = new ItemsDao();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadItems();
            }
        }

        private void LoadItems()
        {
            DataTable tb = itemsDao.getAllItems();
            DataList1.DataSource = tb;
            DataList1.DataBind();
        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {

        }

        protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
        {
            if (e.CommandName == "ImageButton1")
            {
                DataListItem item = (DataListItem)(((ImageButton)(e.CommandSource)).NamingContainer);
                string id = ((Label)item.FindControl("lblid")).Text;
                Session["id"] = id;
                Response.Redirect("HomeDetail.aspx");
            }

        }
    }
}